I have a script that currently has a dialog with a button that, when clicked, starts running the main function of the script which is to loop through all Formal modules and counts the number of times each attribute (both object and module level) is used. Now, though, I would like this button to display a selection dialog to allow the user to choose which attributes they want to search for. I figured that I could create a function that calls this dialog, but it doesn't appear to be working. Here is a segment of my code that I've written:
DB attrTypeBox = centered("Attribute");
string question = "Which attributes do you want displayed?";
string choices[] = {"Object", "Module"};
DBE attrPrint = label(attrTypeBox, "Attributes to print: ");
DBE attrRadio = radioBox(attrTypeBox, "", choices, 0);
string attrSelected = "";
void getData(DBE dbe) {
//Perform main function to get the data needed for Excel worksheet.
}
void selAttrs(DBE btn) {
infoBox("Hello");
int i = get attrRadio;
string attrSelected = choices[i];
hide attrTypeBox;
getData(btn);
}
void selectAttrs(DBE btn) {
apply(attrTypeBox, "Display Attributes", selAttrs);
}
void buildDialog() {
dbMain = create(SCRIPT_NAME, styleCentered|styleFixed);
...
...
dbeRunBtn = button(dbMain, "Run", selectAttrs);
dbeRunBtn->"top"->"inside"->dbeFrame;
//The same is used for left, right and bottom to place the button}
Hopefully, this gives enough information to answer my question. As it stands now, I never get the infoBox that says Hello, so I know I'm not getting into the selAttrs function. Christopher Cote - Fri Jun 21 15:15:25 EDT 2019 |
Re: How to open dialog box from button click Here's an update to my issue: When I try to run this script now, I don't even get the original dialog box. Instead, I get an error that says "incorrect arguments for function (apply)" on the code in line 20 above. I don't understand why I'm getting this error since attrTypeBox is a global variable and the function selAttrs is just above. So what am I doing wrong?
Chris |
Re: How to open dialog box from button click Christopher Cote - Mon Jun 24 10:53:23 EDT 2019 Here's an update to my issue: When I try to run this script now, I don't even get the original dialog box. Instead, I get an error that says "incorrect arguments for function (apply)" on the code in line 20 above. I don't understand why I'm getting this error since attrTypeBox is a global variable and the function selAttrs is just above. So what am I doing wrong?
Chris Hi Chris
Bear with me still nursing my coffee.. is this what you are trying to do?
DB dbMain
void getData(DB dbe) {
void selAttrs(DB btn) {
void selectAttrs(DBE btn) {
dbeRunBtn = button(dbMain, "Run", selectAttrs); Sara |
Re: How to open dialog box from button click Yes, I believe that is what I'm trying to do. I'm trying to have a button start the procedure instead of starting as soon as you select it from the menu.
Chris |
Re: How to open dialog box from button click Looking at the original code, showing lines 1 through 30.
Line 20 "apply" should create an apply button at the bottom of the dialog. This only makes sense while building the dialog, before it is "realize"d or "show"n. Putting it into a callback doesn't make sense at all. I'm surprised you don't get a run time error when you push the "Run" button.
Line 17 "selectAttrs" function is no longer needed. -Louie |